package com.sunni.dao_old.impl;

import com.sunni.dao_old.AccountMapper;
import com.sunni.entity.Account;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class AccountMapperImpl implements AccountMapper {

    // day12-01 : 传统开发
    @Override
    public List<Account> selectAll() throws IOException {
        InputStream resource = org.apache.ibatis.io.Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resource);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        List<Account> accountList = sqlSession.selectList("accountMapper_old.selectAll");
        sqlSession.close();
        return accountList;
    }
}
